﻿﻿﻿@extends('admin.Default')
@section('type')
    <!-- Data Tables -->
    <link href="{{ asset('myadmin/css/plugins/summernote/summernote.css') }}" rel="stylesheet">
    <link href="{{ asset('myadmin/css/plugins/summernote/summernote-bs3.css') }}" rel="stylesheet">
    <link href="{{ asset('myadmin/css/plugins/dropzone/basic.css') }}" rel="stylesheet">
    <link href="{{ asset('myadmin/css/plugins/dropzone/dropzone.css') }}" rel="stylesheet">
@stop
@section('content')
    <style type="text/css">
        body, html{width: 100%;height: 100%;margin:0;font-family:"微软雅黑";font-size:14px;}
        #l-map{height:300px;width:50%;}
        #r-result{width:100%;}
    </style>
    {{--<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=keXdM18CTQm5jrHeydPispemtrz5Y00v"></script>--}}
    <div class="col-md-8" style="margin-top:50px;margin-left:330px;">
        <form method="post" action="/admin/adminself/xiugai" name="upsuper" id="upsuper" enctype="multipart/form-data">
            <input type='hidden' name='_token' value='{{ csrf_token() }}'>
            <input type="hidden" name="id" class="form-control" value="{{ $list->id }}"  >
            <input type="hidden" name="ip" class="form-control" value="127.0.0.1"  >
            {{--可以不写？？--}}
            <div class="form-group row">
                <label class="col-sm-2 control-label">账 &nbsp; &nbsp; &nbsp; 号：</label>
                <div class="col-sm-6">
                    <input type="text" name="username" class="form-control" value="{{ $list->username }}" disabled >
                    <input type="hidden" name="username" class="form-control" value="{{ $list->username }}"  >
                </div>
            </div>
            <div class="form-group row">
                <label class="col-sm-2 control-label">新 密　码：</label>
                <div class="col-sm-6">
                    <input type="password" name="password" class="form-control"  placeholder="密码">
                </div>
            </div>
            <div class="form-group row">
                <label class="col-sm-2 control-label">确认密码：</label>
                <div class="col-sm-6">
                    <input type="password" name="pwd" class="form-control"  placeholder="确认密码"  onblur="pass(this);">
                </div>
            </div>
            {{--<div class="form-group row">--}}
                {{--<label class="col-sm-2 control-label">头像：</label>--}}
                {{--<div class="col-sm-10">--}}
                    {{--@if (count($list->pic ))--}}
                        {{--<a data-toggle="modal"  href="#modal-form-photo" onclick="editImg(this)"><img src="{{ url('/upload/admin/'.$list->pic) }}" width="150" onclick="subHid(this)"></a>--}}
                    {{--@else--}}
                        {{--<a  data-toggle="modal" class="btn btn-primary" href="#modal-form-photo" style="float:left;" onclick="subHid(this)">添加图片</a>--}}
                    {{--@endif--}}
                {{--</div>--}}
            {{--</div>--}}
            <div class=" form-group row">
                <div class="form-group">
                    <label class="col-sm-2 control-label">等 &nbsp; &nbsp; &nbsp; 级：</label>
                    <div class="col-sm-10">
                        <select  name="level" id="level" class="col-sm-7" style="padding:6px 12px; ">
                            <option value="1" @if ($list->level == 1)  selected    @endif >普通管理员</option>
                            <option value="2"  @if ($list->level == 2)  selected    @endif>超级管理员</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="form-group row">
                <label class="col-sm-2 control-label">状态：</label>
                <div class="col-sm-4">
                    <label class="radio-inline">
                        <input type="radio" @if ($list->status == 1)  checked    @endif value="1" id="optionsRadios1" name="status">正常</label>
                    <label class="radio-inline">
                        <input type="radio" value="2" @if ($list->status == 2)  checked    @endif id="optionsRadios2" name="status">冻结</label>
                </div>
            </div>

            <button class="btn btn-primary" type="button" onclick="updatesuper()" style="margin-left: 200px;"><strong>提交</strong></button>
            <button class="btn btn-primary" type="reset"><strong>重置</strong></button>
        </form>
    </div>
    <div id="modal-form-photo" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-body">
                    <div class="row">
                        <div class="col-sm-12">
                            <button class="close"
                                    data-dismiss="modal">&times;
                            </button>
                            <h3 class="m-t-none m-b" id="up_img">添加图片</h3>

                            <form action='/admin/super/editLogo' method='post' enctype='multipart/form-data'>
                                <input type='hidden' name='_token' value='{{ csrf_token() }}'>
                                <input type='hidden' name='id' id="hid">
                                <div class="list list-title">

                                    <li class="head"><i>我的头像：</i><img id="pic" src="" width="80">
                                        <input style="display: none" type="file" id="img" name="photo" >
                                        <button type="button" onclick="demo();"  >点击上传<br></button>
                                    </li>
                                    </ul>

                                </div>
                                <button class="btn btn-sm btn-primary pull-right m-t-n-xs" type="submit"
                                ><strong>提交</strong>
                                </button>
                            </form>



                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
@stop
@section('script')
    <!-- SUMMERNOTE -->
    <script src="{{ asset('myadmin/js/plugins/summernote/summernote.min.js') }}"></script>
    <script src="{{ asset('myadmin/js/plugins/summernote/summernote-zh-CN.js') }}"></script>
    <script src="{{ asset('myadmin/js/plugins/dropzone/dropzone.js') }}"></script>
    <script src="{{ asset('tools/form-builder/beautifyhtml.js') }}"></script>
    <script src="{{ asset('myadmin/js/jquery.md5.js') }}"></script>
    <script>
        function pass(bn){
            var pwd = $(bn).val();
            var password = $("input[name=password]").val();

            if(pwd == ""){
                alert("确认密码不能为空！");
            }else{
                if(pwd != password){
                    alert("两次密码不一致！");
                }
            }

        }

        function updatesuper() {
            var id = $("input[name=id]").val();
            var method = $("input[name=_method]").val();
            var username = $("input[name=username]").val();
            var password =$.md5($("input[name=password]").val());
            var pass = $("input[name=pwd]").val();
            var pstatus=$("input[type=radio]:checked").val();
            var level=$("#level").val();
            if (username == '' || password == '' || pass == '') {
                alert("请将信息填写完整！");
            }else{
                $('#upsuper').submit();
            }
        }

        function demo(){
            $("#img").click();  //隐藏了input:file样式后，点击头像就可以本地上传
            $("#img").on("change",function(){
                var objUrl = getObjectURL(this.files[0]) ; //获取图片的路径，该路径不是图片在本地的路径
                if (objUrl) {
                    $("#pic").attr("src", objUrl) ; //将图片路径存入src中，显示出图片
                }
            });
        }


        //建立一個可存取到該file的url
        function getObjectURL(file) {
            var url = null ;
            if (window.createObjectURL!=undefined) { // basic
                url = window.createObjectURL(file) ;
            } else if (window.URL!=undefined) { // mozilla(firefox)
                url = window.URL.createObjectURL(file) ;
            } else if (window.webkitURL!=undefined) { // webkit or chrome
                url = window.webkitURL.createObjectURL(file) ;
            }
            return url ;
        }

        function subHid(obj) {
            //获取原节点id
            hid ={{ $list->id }};
            //did =  $(obj).parent().parent().attr('id');
            src = $(obj).attr('src');
            //把原节点名添加到模态框
            $('#pic').attr('src',src);
            //把原节点名添加到模态框
            $('#hid').val(hid);
        }

        function editImg(obj){
            //did =  $(obj).parent().parent().attr('id');
            $('#up_img').html('更改图片');

        }
    </script>

    <script>
        $(document).ready(function () {

            $('.summernote').summernote({
                lang: 'zh-CN'
            });

        });
    </script>
@stop
